#include "HelpFunc.h"
#include <ctype.h>

using std::string;

#define M_BLANK_SPACE " \t\r\n"

void TrimBlank(std::string& str)
{
	string::size_type first = str.find_first_not_of(M_BLANK_SPACE);
	if (first == string::npos)
	{
		str.clear();
		return;
	}

	string::size_type last = str.find_last_not_of(M_BLANK_SPACE);
	if (last == string::npos)
	{
		last = str.size();
	}

	str = str.substr(first, last-first+1);
}

void ToLower(std::string& str)
{
	string::size_type index;

	for (index = 0; index < str.size(); index++)
	{
		if (isupper(str[index]))
		{
			str[index] = tolower(str[index]);
		}
	}
}

int RandGet(int nMaxValue)
{
	srand((unsigned int)time(0));
	int nValue = rand()%nMaxValue;

	return nValue;
}